package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.IDailyFeedbackDeleteView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.DailyFeedbackDeleteModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IDailyFeedbackDeleteModel;

public class DailyFeedbackDeletePresenter {
    private IDailyFeedbackDeleteView view;
    private IDailyFeedbackDeleteModel model;
    private Handler handler = new Handler();

    public DailyFeedbackDeletePresenter(IDailyFeedbackDeleteView view) {
        this.view = view;
        this.model = new DailyFeedbackDeleteModel();
    }

    public void dailyFeedbackDelete() {
        model.dailyFeedbackDelete(view.getOrderId(), view.getProductId(), view.getWorkPartFeedbackId(), view.getWorkPartId(), view.getWorkPartOrderId(), new DailyFeedbackDeleteModel.OnDailyFeedbackDeleteListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getDailyFeedbackDeleteSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getDailyFeedbackDeleteFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
